package com.example.springboot.factorys;

import com.example.springboot.enums.ServiceEnum;
import com.example.springboot.service.BaseService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class BaseServiceFactory {

    @Resource
    private List<BaseService> services;

    public BaseService findBy(ServiceEnum serviceEnum) {
        for (BaseService baseService : services) {
            if (baseService.serviceTypeProvide().equals(serviceEnum)) {
                return baseService;
            }
        }
        return null;
    }
}
